
import 'package:erp/Store/AccountStore.dart';
import 'package:erp/UI/Components/MessageDialog.dart';
import 'package:flutter/material.dart';
import 'dart:io';
import "../Components/ListDividerGenerator.dart";

class UserCenter extends StatelessWidget {
  @override
  Widget build(BuildContext context) => UserCenterStateful();
}

class UserCenterStateful extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => UserCenterState();
}

class UserCenterState extends State<UserCenterStateful> {
  List<Widget> divideredOptions;
  @override
  void initState() {
    super.initState();
    divideredOptions = ListDividerGenerator(getOptions(), Divider()).items;
  }
  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: <Widget>[
        SliverAppBar(
          actions: <Widget>[
            IconButton(icon: Icon(Icons.close), onPressed: (){

            })
          ],
          pinned: true,
          expandedHeight: 220.0,
          flexibleSpace: FlexibleSpaceBar(
            title: Text(
              "خۇش كىلىپسىز ${AccountStore.signInResult.name}",
              style: TextStyle(fontSize: 16.0),
            ),
            centerTitle: true,
            background: Container(
                width: double.infinity,
//                color: Theme.of(context).primaryColor,
                child: Align(
                  child: CircleAvatar(
                    backgroundImage: AssetImage("assets/pictures/boy.png"),
                    backgroundColor: Colors.white,
                    radius: 64.0,
                  ),
                )),
          ),
        ),
        SliverList(
          delegate: SliverChildListDelegate(divideredOptions)
        )
      ],
    );
  }

  List<Widget> getOptions() => [
        Row(
          children: <Widget>[
            Icon(Icons.person),
            Expanded(
              child: ListTile(
                title: Text("ماتېرىيالىڭىزنى كۆرۈڭ"),
                subtitle: Text("بارلىق ئۇچۇرلىرىڭىزنى كۆرەلەيسىز"),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Icon(Icons.edit),
            Expanded(
              child: ListTile(
                title: Text("ماتېرىيالىڭىزنى تەھرىرلەڭ"),
                subtitle:
                    Text("ھىسابات نامى، پارول قاتارلىقلارنى ئۆزگەرتەلەيسىز"),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Icon(Icons.import_contacts),
            Expanded(
              child: ListTile(
                title: Text("مەن كىرگۈزگەن ماللار"),
                subtitle: Text(
                    "سىز كىرگۈزگەن ماللارنىڭ تەپسىلاتىنى بۇ يەردىن كۆرەلەيسىز"),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Icon(Icons.import_export),
            Expanded(
              child: ListTile(
                title: Text("مەن ساتقان ماللار"),
                subtitle:
                    Text("بۇ يەردىن سىز ساتقان ماللار ئۇچۇرىغا ئىرىشەلەيسىز"),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Icon(Icons.people),
            Expanded(
              child: ListTile(
                title: Text("مال تەمىنلىگۈچىلىرىم تىزىملىكى"),
                subtitle: Text(
                    "سىزگە مال تەمىنلىگەن مال تەمىنلىگۈچىلەرنى كۆرەلەيسىز"),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Icon(Icons.people),
            Expanded(
              child: ListTile(
                title: Text("بۈگۈنكى خىرىدارلىرىم تىزىملىكى"),
                subtitle: Text(
                    "بۈگۈن سىز مال ساتقان خرىىدارلار تىزىملىكىنى كۆرەلەيسىز"),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Icon(Icons.settings),
            Expanded(
              child: ListTile(
                title: Text("تەڭشەكلەر"),
                subtitle:
                    Text("بۇ يەردىن سىستېمىغا قارىتا تەڭشەش ئىلىپ بارالايسىز"),
              ),
            )
          ],
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            GestureDetector(
              child: Container(
                  width: 120.0,
                  margin: EdgeInsets.symmetric(vertical: 20.0),
                  padding: EdgeInsets.symmetric(vertical: 10.0),
                  decoration: BoxDecoration(
                      color: Colors.redAccent,
                      borderRadius: BorderRadius.circular(10.0)),
                  child: Text(
                    "چىكىنىش",
                    textAlign: TextAlign.center,
                    style: TextStyle(color: Colors.white),
                  )),
              onTap: () {
                showMessageDialog(context, title: "Error", content: "This feature is current not implemented");
              },
            )
          ],
        )
      ];
}
